// -- ----------- 严晴---------- --
import apis from '../../http/api/apis'

export default {
    namespaced: true,
    state: {
        adminToCustomers: [],
        pageSize: 3,  //  每页显示的条数
        currentPage: 1,  //  当前页数
        total: 0,   //  数据总条数
        pages: 0,  //  总页数
        allClients:""//所有用户

    },
    mutations: {
        setAdminToCustomers(state, data) {
            state.adminToCustomers = data.customers;
            state.total = data.total;
            state.pages = data.currentPage;
            state.allClients = data.result;
        },
        //  改变每页显示条数
        changePageSize(state, pageSize) {
            state.pageSize = pageSize;
        },
        //  改变当前页
        changeCurrentPage(state, currentPage) {
            state.currentPage = currentPage;
        },
    },
    actions: {
        //  获取管理员页面客户列表
        async getAdminToCustomers(context) {
            var { data } = await apis.adminCustomers.getAdminToCustomers({
                pageSize: context.state.pageSize,
                currentPage: context.state.currentPage,
            });
            // console.log(data.data);
            if (data.code) {
                //  获取成功
                context.commit('setAdminToCustomers', data.data)
            } else {
                console.log('获取失败');
            }
        },
        //销售增加订单 获取所有客户
        async getCustomersAllId(context) {
            var { data } = await apis.adminCustomers.getCustomersAllId();
            console.log(data);
            if (data.code) {
                //  获取成功
                context.commit('setAdminToCustomers', data)
            } else {
                console.log('获取失败');
            }
        },

    }
}
